home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / bitmap / bitmap.doc next >
Text File  |  1991-07-20  |  4KB  |  73 lines

  1.  
  2. Experiments with Bitmaps, hDCs, Images, Pictures, and AutoRedraw
  3. ----------------------------------------------------------------
  4.  
  5. I gave up trying to write a dozen different sample programs to figure
  6. out what's going on with VB, AutoRedraw, hDC and the Windows GDI. So, I
  7. wrote a program (actually drew a form, the code was no big deal) which
  8. exercises pretty much all of the graphics methods in terms of refreshing,
  9. cls, pset/line, etc., along with the GDI stuff like BitBlt, and the GDI
  10. line drawing (MoveTo, LineTo, SetPixel, etc.).  There are 2 picture box
  11. controls (labelled P1 [left] and P2 [right]) which you can transfer from
  12. one to the other using either VB's transfer (e.g., P2.Picture = P1.Image),
  13. copy to the clipboard, etc.  P1 is the source for most operations, and you
  14. can draw on it by clicking and hold the left mouse button and then moving
  15. around to draw freehand.  You'll be drawing with the VB statements to
  16. start with, but if you click the VB Draw Mode command button, it'll toggle
  17. you to GDI drawing, and if you click again you'll be back in VB mode.  A
  18. quick note about GDI drawing, if AutoRedraw is on (see the checkbox), the
  19. you won't see what you're drawing until you do a Refresh or if you have
  20. the GDI Draw Auto-Refresh checked which will do a .Refresh method
  21. everytime a GDI statement is executed (LineTo, BitBlt, etc.).
  22.  
  23. The BitBlt-->Image button will BitBlt the picture's "screen" to the
  24. .Image.  Confused?  Take a look at the code, play with it and it'll become
  25. less confusing (no claims on making it clear!).
  26.  
  27. P2 is the destination for the BitBlt, and VB's transfer methods.  Note the
  28. option buttons settings which determine whether the .Picture or .Image
  29. property will be used for ClipBoard functions and VB transfer.  Note that
  30. in some cases if .Image is selected, it won't be used as a destination
  31. since it's a read-only property.  In those cases, the program will only
  32. use the .Picture property.  However, there's always a status message
  33. displayed so you'll know what you're getting.  Also note that there is a
  34. list box where you can choose which BitBlt mode to use.  In a future
  35. version I'll allow Raster Operations (ROPs) other than the normal ones to
  36. be entered.  There are some pretty interesting combinations.
  37.  
  38. Hide Picture and Disable Picture affect the .Visible and .Enabled
  39. properties, respectively.  The buttons will change to let you know what
  40. action will be taken when they're clicked.  Image-->Picture will copy that
  41. picture's .Image Property to the .Picture property, i.e., .Picture=.Image.
  42.  
  43. The RGB colored boxes below each picture will bring up a dialog box
  44. allowing you to set the Foreground and Background colors.  Note that if
  45. the color is initally set to an indexed system color (e.g., &H80000005 or
  46. COLOR_WINDOW), the routine will convert it to an RGB color (e.g.,
  47. &H00FFFFFF).  I would've converted the color back to a system color (if
  48. possible), but it doesn't necessarily make sense to do so and I don't know
  49. of a function that'd do it anyway (besides to go through each system color
  50. looking for a match).
  51.  
  52. The PopOver button will pop up a large dialog box which should cover the
  53. picture boxes which gives you another way to see AutoRedraw in action.
  54. Click on "I've Had It!" when you've had enough and need to get some sleep.
  55.  
  56. I think that pretty much covers the basics, the rest is left as an
  57. exercise for the user (that's you), since that's what this thing is for!
  58. Let me know if you have any questions or problems.  I coded it on an
  59. 800x600 screen, but I'm pretty sure I sized it properly for a 640x480
  60. screen.  If not, let me know and I'll load up my 640x480 driver and fix
  61. it.  Have fun with it!
  62.  
  63.                                  - Ted Young
  64.                                  [76703,4343]
  65.  
  66. p.s. While the the LoadPicture() function gives you the ability
  67. to load a bitmap/metafile into the picture boxes, the SavePicture() is
  68. currently not implemented (I got tired of playing with it).
  69.  
  70. I'm planning on doing some stuff with the GDI region and clipping
  71. functions sometime soon. If you have any comments or suggestions, please
  72. let me know!
  73.